﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BusLib
{
    public partial class Agency
    {
        public static Agency ImportCSV(string line)
        {
            Agency a = null;
            string[] fields = line.Split(',');

            if (fields[0] != "agency_id")
            {
                a = new BusLib.Agency();
                a.agency_id = fields[0];
                a.agency_name = fields[1];
                a.agency_url = fields[2];
                a.agency_timezone = fields[3];
                a.agency_lang = fields[4];
                a.agency_phone = fields[5];

                BusLibDataContext db = BusLibDataContext.db;
                db.Agencies.InsertOnSubmit(a);
                db.SubmitChanges();
            }
            return a;
        }
    }
}
